<template>
  <div class="userdetail">
    <div>
      <div class="user_edit">
        <div style="display: flex;">
          <p>
            <span>{{ likeData.fans }}</span>
            <span class="user_text">粉丝</span>
          </p>
          <p>
            <span>{{ likeData.follow }}</span>
            <span class="user_text">关注</span>
          </p>
          <p>
            <span>{{ likeData.like }}</span>
            <span class="user_text">获赞</span>
          </p>
        </div>

        <div class="option">
          <div @click="getManege" class="items">
            <div class="item">管理</div>
          </div>

          <div @click="getUpload" class="items">
            <div class="item">投稿</div>
          </div>
          <div @click="$router.push('/edit')" class="items">
            <div class="item">编辑</div>
          </div>
          <div @click="out" class="items">
            <div class="item">注销</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  props: ["userInfo"],
  data() {
    return {
      likeData: {
        fans: "",
        like: "",
        follow: "",
      },
    };
  },
  computed: {
    ...mapGetters(["user", "isLogin"]),
  },
  methods: {
 
    async SelectLikeData() {
      const { data: res } = await this.$http.get(
        "/follow/nums/" + this.user.id
      );
      this.likeData.fans = res.data.fans;
      this.likeData.follow = res.data.follow;
      const { data: likes } = await this.$http.get(
        "/likes/likeme/" + this.user.id
      );
      this.likeData.like = likes.data;
    },

    getUpload() {
      this.$emit("uploadView");
    },
    getManege() {
      this.$emit("manageView");
    },
     out(){
      this.$store.commit('setUser', null);
      this.$store.commit('setIsAdmin', false);
      this.$router.push("/")
    }
  },
  created() {
    this.SelectLikeData();
  },
};
</script>

<style scoped lang="less">
.userdetail {
  width: 25vw;
  height: 15vh;
  padding: 1vh 3vw;


    .user_edit {
      flex: 1;
        p {
          flex: 1;
          display: flex;
          justify-content: center;
          align-items: center;
          flex-direction: column;
          font-size: 0.85vw;
          .user_text {
            color: #aaa;
          }
        }
        p:nth-child(1),
        p:nth-child(2) {
          border-right: 0.178vw solid #ccc;
        }
    
    }
  

  .option {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: .8rem;
    margin-top: 2vh;

    .items {
      margin-left: 1vw;
      .item {
        border: 0.2vw solid #fb7a9f;
        padding: 0.2vh 0.5vw;
        cursor: pointer;
        color: #fb7a9f;
        border-radius: 10%;
      }
    }
  }
}
</style>